<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <title>title</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/js/layui-v2.4.5/layui/css/layui.css}" media="all" />
    <style>
        .required_color{
            color: red;
        }
        body{ padding-bottom:50px;}

        .layui-form-item{margin:0px 40px 15px 40px;}
    </style>
</head>
<body style="-webkit-backface-visibility: hidden;">
<div class="layui-row">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" style="margin-top: 15px;">
        <form id="form" class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label required_color">客户号码</label>
                    <div class="layui-input-block">
                        <input type="text" name="badPhone" required  lay-verify="required" placeholder="请输入需要封存的号码" autocomplete="off" class="layui-input" maxlength="20" th:value="${badCustomerPhone.badPhone}">
                    </div>
                </div>

            </div>
            <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label required_color">来源</label>
                <div class="layui-input-block">
                    <input type="text" name="source" required placeholder="请输入来源" autocomplete="off" class="layui-input" maxlength="15"  th:value="${badCustomerPhone.source}">
                </div>
            </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">说明</label>
                <div class="layui-input-block">
                    <textarea name="remark" placeholder="请输入说明" class="layui-textarea" maxlength="40" th:text="${badCustomerPhone.remark}"></textarea>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-input-block" style="text-align: center">
                    <button type="button" class="layui-btn layui-btn-normal" id ="back">返回</button>
                    <button   class="layui-btn" lay-submit lay-filter="save">保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>

<script th:src="@{/js/jquery-2.1.1.min.js}"></script>
<script th:src="@{/js/layui-v2.4.5/layui/layui.js}"></script>
<script th:inline="javascript">
    var badCustomerPhone = [[${badCustomerPhone}]];
    /*当前窗口数据*/
    layui.use(['table','form'], function() {
        var table = layui.table,
            form = layui.form;
        var layer = parent.layer === undefined ? layui.layer : parent.layer;


        $("#back").click(function () {
            var index=layer.getFrameIndex(window.name); //获取当前窗口的name
            console.log(index)
            layer.close(index);
        })

        /**
         *
         *监听提交
         * */
        form.on('submit(save)', function(data){
            var load = layer.load();
            var data = data.field;
            console.log("提交数据:"+data);
            $.ajax({
                type: "POST",
                url:   "/fsm/external/badCustomerPhone/save",
                dataType:"json",
                data:data,
                success: function (data) {
                    layer.close(load);
                    if(data.code=="1"){
                        layer.msg(data.msg,{icon: 6})
                        window.parent.hasSave=true;
                        var index=layer.getFrameIndex(window.name); //获取当前窗口的name
                        layer.close(index);
                    }else{
                        layer.msg(data.msg,{icon: 5})
                    }
                },
                error: function (msg) {
                    layer.close(load);
                }
            });
            return false;
        });
    });

</script>

</html>
